<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>账单续期</title>
<link href="/dist/css/all_min.css" tppabs="http://www.115yz.com/xjkc/dist/css/all_min.css" rel="stylesheet">
</head>
<body>
<!--页头 start-->
<div id="header" class="kc-fixed kc-boxBody kc-commonHeight kc-commonbg">
    <div class="kc-rel">   
        <div class="float-left kc-cannel kc-pos">
             <div class="icon-bar" onclick="backUrl()"></div>
        </div>
        <a class="float-left kc-title textCenter">账单续期</a>
         <!-- <img src="/dist/img/msg.png" class="kc-msg"> -->
    </div>
</div>
<!--页头 end-->
<!--主体 start-->
<div id="bodyer" class="kc-padbody kc-boxBody renewal-body">
    <div><img width='100%' src="/dist/img/order-renewal.png">
        <div class="first"><span >延期费用&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DBA86D">¥<?php echo $_GET['xuMoney'] ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></div>
        <div class="sec"><span>延期后应还日期</span><span><?php echo $_GET['day'] ?></span></div>
        <div class="third"><img src="/dist/img/point.png" class="circle" onclick="changeImg(this)"><spans style="color: #9B9B9B; margin-top: -3px; margin-left: 5px; position: relative;">我已阅读并同意<a style="text-decoration: underline; color: #DBA86D" href="#">《延期协议》</a></spans></div>
    </div>
    <div><img width='100%' style="margin-top: 25px;" src="/dist/img/comfirm-renewal.png" onclick="returnNow()"></div>  
</div>
<!--主体 end-->
<!--页脚 start-->
<!--页脚 end-->
<script src="/resourse/jquery/jquery-1.11.3.min.js" tppabs="http://www.115yz.com/xjkc/resourse/jquery/jquery-1.11.3.min.js"></script>
<script src="/dist/js/all_min.js" tppabs="http://www.115yz.com/xjkc/dist/js/all_min.js"></script>
<script src="/dist/js/july.js" tppabs="http://www.115yz.com/xjkc/dist/js/all_min.js"></script>
<script type="text/javascript">

let hostname = 'http://'+location.host;
    function oval(img){
        if(img.src ==hostname+'/dist/img/Oval.png'){
            img.src ="/dist/img/OO.png";//变实 其他按钮变空
            let divs = $(img).parent().siblings('.paypay').find('img.oval') ;
            for(let i=0; i<divs.length;i++){
                divs[i].src="/dist/img/Oval.png";
            }
        }else{
            img.src ="/dist/img/Oval.png"    
        }
    }




    function changeImg(img){
          let hostname = 'http://'+location.host;
       if(img.src ==hostname+'/dist/img/point.png'){
          img.src ="/dist/img/checked.png"    
       }else{
          img.src ="/dist/img/point.png"    
       }
    }


    function returnNow(){
        let is = isReadProtocol()
        if(is==false) return false;
        //唤起支付方式遮罩层
        let returnMoney = <?php echo isset($_GET['xuMoney']) && !empty($_GET['xuMoney'])? $_GET['xuMoney']:0 ?>;
        let bankName = "<?php echo  isset($_GET['bankName']) && !empty($_GET['bankName'])? $_GET['bankName']:0 ?>";
        let cardNum =<?php echo isset($_GET['cardNum']) && !empty($_GET['cardNum']) ? $_GET['cardNum']:0 ?>;
        let Type =2;//展期
        payShadow(bankName,cardNum,returnMoney,Type);
    }


    function payShadow(a,b,c,d){
        let html;
        html ='<div class="modal-window"><div class="modal-shadow" onclick=removeShadow()></div>\
        <div class="payBtn">\
            <div class="top">立即还款</div>\
            <div class="top top2"><span class="money">¥</span>'+c+'</div>\
            <div class="top top3">现金滴滴延期还款费用</div>\
            <div class="paypay"><img src="/dist/img/weixin.png"><span>微信支付</span><img src="/dist/img/Oval.png" onclick="oval(this)" class="oval" data-id=0></div>\
            <div class="paypay"><img src="/dist/img/ziyuan.png"><span>支付宝支付</span><img src="/dist/img/Oval.png" onclick="oval(this)"  class="oval" data-id=1></div>\
            <div class="paypay"><img src="/dist/img/yinlian.png"><span>'+a+'('+b+')</span><img src="/dist/img/Oval.png" onclick="oval(this)"  class="oval"data-id=2></div>\
            <div><span><img src="/dist/img/pay.png" id="pays" onclick="pays('+c+','+d+')"></span></div>\
            </div>\
        </div>';
        $('body').append(html); 
    }

    //主支付方式 银行卡
    function pays(c,d){
        //选择支付方式
        let payway = $('.payBtn div img.oval');
        let data = {};
        data.name = "<?php  echo $user['TrueName'] ?>";
        data.Id ="<?php  echo $user['IDCard'] ?>";
        data.mobile ="<?php if(isset($bankData)){ echo $bankData['YMobile']; }else{ echo '' ;} ?>";
        data.BankNo ="<?php if(isset($bankData)){ echo $bankData['BankNo']; }else{ echo '' ;} ?>";
        data.OrderSn= "<?php if(isset($applyData)){ echo $applyData['OrderSn']; }else{ echo '' ;} ?>";
        data.Money=c;
        data.Type=2;
        let count =0;
        for(let i=0;i<payway.length;i++){
            if(payway[i].src==hostname+'/dist/img/OO.png'){
                count++;
                let dataId = $(payway[i]).attr('data-id');
                if(dataId==0){
                    openTip('微信支付尚未开通');
                } else if(dataId==1) {
                    openTip('支付宝支付尚未开通');
                }else{
                     $.ajax({
                         url:'/api.php/bank/pay',
                         type:'POST',
                         data:data,
                         success:function(data){
                            //  console.log(data);return;
                            let json = JSON.parse(data);
                            if(json.status==1){
                                window.location.href=json.data;
                            }else{
                                openTip(json.data);
                                return false;   
                            }
                         }
                     })
                }
            }
        }
      if(count==0){
        openTip("尚未选择支付方式");
        return false;
      }
    }

    
    function isReadProtocol(){
    let proto = $('.circle').attr('src')
    if(proto!=='/dist/img/checked.png'){
        openTip('请同意《延期协议》')
        return false 
    }
}



</script>
</body>
</html>